﻿using System;
using System.Collections.Generic;
namespace MSDNWebcast.Models
{
    /// <summary>
    /// 课程系列
    /// </summary>
    public class CourseCatalog
    {
        public CourseCatalog()
        {
            Courses = new List<Course>();
        }

        /// <summary>
        /// 产品
        /// </summary>
        public string Product { get; set; }

        /// <summary>
        /// 系列名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 讲师
        /// </summary>
        public string Speaker { get; set; }

        /// <summary>
        /// 课程日期
        /// </summary>
        public DateTime Date { get; set; }

        /// <summary>
        /// 技术
        /// </summary>
        public string Technology { get; set; }

        /// <summary>
        /// 课程列表
        /// </summary>
        public List<Course> Courses { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public bool HasDownload()
        {
            foreach (var course in Courses)
            {
                if (course.HaveDownload())
                    return true;
            }
            return false;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (obj != null && obj is CourseCatalog && !ReferenceEquals(obj, this))
                return ((CourseCatalog)obj).Name == this.Name;
            return base.Equals(obj);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return this.Name;
        }
    }
}
